const {LANG} = require('../config/default')

/**
 * 获取本地保存的语言配置
 * @param load {boolean} 是否加载配置中的语言
 * @returns {Object}
 */
function getLocalLang(loadLang) {
  let localLang = {}
  try {
    const localLangStr = localStorage.getItem(process.env.VUE_APP_LANG_KEY)
    localLang = JSON.parse(localLangStr)
  } catch (e) {
    console.error(e)
  }
  if (loadLang) {
    if (!localLang) {
      localLang = LANG
    }
  }
  return localLang
}

module.exports = {
  getLocalLang
}